package com.coocaa.ops.admin.v1.panel.convert;

import com.coocaa.ops.admin.v1.panel.model.PanelInfoModel;
import com.coocaa.ops.common.core.base.util.PageQueryUtil;
import com.coocaa.ops.common.core.biz.panel.constant.PanelTypeConstants;
import lombok.experimental.UtilityClass;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;

import java.util.Map;

/**
 * @author bijiahao
 * @description
 * @date 2020/6/28 14:49
 */
@UtilityClass
public class PanelQueryConverter {

    public static Map<String, Object> getQueryMap(PanelInfoModel model){
        if(ArrayUtils.isEmpty(model.getPanelTypeArray()) && StringUtils.isBlank(model.getPanelType())){
            String[] panelTypeArray = new String[]{PanelTypeConstants.NORMAL,PanelTypeConstants.GROUP,PanelTypeConstants.PLUGIN,PanelTypeConstants.REC_STREAM};
            model.setPanelTypeArray(panelTypeArray);
        }
        Map<String, Object> params = PageQueryUtil.getFilterMap(model);
        return params;
    }
}
